package utils 
{
	import flash.display.BitmapData;
	import flash.display.DisplayObjectContainer;
	import flash.display.InteractiveObject;
	import flash.filters.ColorMatrixFilter;
	import resource.ImageResource;
	import resource.Resource;
	/**
	 * ...
	 * @author carlor
	 */
	public class clientUtils 
	{
		static public const grayColorMatrix: Array = [0.3086, 0.6094, 0.0820, 0, 0, 
													  0.3086, 0.6094, 0.0820, 0, 0, 
													  0.3086, 0.6094, 0.0820, 0, 0, 
													  0, 0, 0, 1, 0];

		public function clientUtils() 
		{
			
		}
		
		
		static public function disenable(obj: InteractiveObject, enable: Boolean = false): void
		{
			if (! enable) {
				obj.filters = [new ColorMatrixFilter(grayColorMatrix)];
				obj.mouseEnabled = false;
				if (obj is DisplayObjectContainer) DisplayObjectContainer(obj).mouseChildren = false;
			}else {
				obj.filters = [];
				obj.mouseEnabled = true;
				if (obj is DisplayObjectContainer) DisplayObjectContainer(obj).mouseChildren = true;
			}
		}
		
		static public function loadImage(fileName: String, callBack: Function): ImageResource
		{
			var r: Resource = Engine.resourceManager.getResource(fileName, ImageResource);
			if (r && (r is ImageResource) && r.isLoaded)
				return ImageResource(r);
			else {
				Engine.resourceManager.loadResource(fileName, ImageResource, callBack);
				return null;
			}
			
		}
	}

}